package com.zhang;

import com.zhang.dao.BookDao;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class App03 {
    public static void main(String[] args) {
        //获取IOC容器
        ApplicationContext ac = new ClassPathXmlApplicationContext("applicationContext.xml");

        //获取id为bookDao的bean对象
        BookDao bookDao = (BookDao) ac.getBean("bookDao");

        //运行实现类的方法
        bookDao.sava();

        //创建ClassPathXmlApplicationContext对象
        ClassPathXmlApplicationContext cptx = new ClassPathXmlApplicationContext("applicationContext.xml");
        cptx.registerShutdownHook();

        cptx.close();


    }
}
